/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.jrk_verwaltung.design.personen;

import de.jrk_verwaltung.security.user.CUser;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * 
 * @author JRK-FO
 */
@Entity
@Table(name = "jrk_personen")
@XmlRootElement
@NamedQueries({ @NamedQuery(name = "CPerson.findAll", query = "SELECT j FROM CPerson j"), @NamedQuery(name = "CPerson.findByIdperson", query = "SELECT j FROM CPerson j WHERE j.idperson = :idperson"),
        @NamedQuery(name = "CPerson.findByMitgliedsnummer", query = "SELECT j FROM CPerson j WHERE j.mitgliedsnummer = :mitgliedsnummer"),
        @NamedQuery(name = "CPerson.findByName", query = "SELECT j FROM CPerson j WHERE j.name = :name"),
        @NamedQuery(name = "CPerson.findByVorname", query = "SELECT j FROM CPerson j WHERE j.vorname = :vorname"),
        @NamedQuery(name = "CPerson.findByGeburtsdatum", query = "SELECT j FROM CPerson j WHERE j.geburtsdatum = :geburtsdatum"),
        @NamedQuery(name = "CPerson.findByStrasse", query = "SELECT j FROM CPerson j WHERE j.strasse = :strasse"),
        @NamedQuery(name = "CPerson.findByPlz", query = "SELECT j FROM CPerson j WHERE j.plz = :plz"), @NamedQuery(name = "CPerson.findByOrt", query = "SELECT j FROM CPerson j WHERE j.ort = :ort"),
        @NamedQuery(name = "CPerson.findByTelefon", query = "SELECT j FROM CPerson j WHERE j.telefon = :telefon"),
        @NamedQuery(name = "CPerson.findByMobil", query = "SELECT j FROM CPerson j WHERE j.mobil = :mobil"),
        @NamedQuery(name = "CPerson.findByEmail", query = "SELECT j FROM CPerson j WHERE j.email = :email"),
        @NamedQuery(name = "CPerson.findByBeruf", query = "SELECT j FROM CPerson j WHERE j.beruf = :beruf"),
        @NamedQuery(name = "CPerson.findByEintrittsdatum", query = "SELECT j FROM CPerson j WHERE j.eintrittsdatum = :eintrittsdatum"),
        @NamedQuery(name = "CPerson.findByAustrittsdatum", query = "SELECT j FROM CPerson j WHERE j.austrittsdatum = :austrittsdatum"),
        @NamedQuery(name = "CPerson.findByFunktion", query = "SELECT j FROM CPerson j WHERE j.funktion = :funktion"),
        @NamedQuery(name = "CPerson.findByBeziehung", query = "SELECT j FROM CPerson j WHERE j.beziehung = :beziehung") })
public class CPerson implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idperson")
    private Integer idperson;
    @Column(name = "mitgliedsnummer")
    private String mitgliedsnummer;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @Column(name = "vorname")
    private String vorname;
    @Column(name = "geburtsdatum")
    @Temporal(TemporalType.TIMESTAMP)
    private Date geburtsdatum;
    @Basic(optional = false)
    @Column(name = "strasse")
    private String strasse;
    @Basic(optional = false)
    @Column(name = "plz")
    private String plz;
    @Basic(optional = false)
    @Column(name = "ort")
    private String ort;
    @Basic(optional = false)
    @Column(name = "telefon")
    private String telefon;
    @Column(name = "mobil")
    private String mobil;
    @Column(name = "email")
    private String email;
    @Column(name = "beruf")
    private String beruf;
    @Column(name = "eintrittsdatum")
    @Temporal(TemporalType.TIMESTAMP)
    private Date eintrittsdatum;
    @Column(name = "austrittsdatum")
    @Temporal(TemporalType.TIMESTAMP)
    private Date austrittsdatum;
    @Column(name = "funktion")
    private String funktion;
    @Column(name = "beziehung")
    private String beziehung;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkIdperson", fetch = FetchType.EAGER)
    private Collection<CUser> jrkUserCollection;
    @OneToMany(mappedBy = "fkIdperson", fetch = FetchType.EAGER)
    private Collection<CPerson> CPersonCollection;
    @JoinColumn(name = "fk_idperson", referencedColumnName = "idperson")
    @ManyToOne(fetch = FetchType.EAGER)
    private CPerson fkIdperson;

    public CPerson() {
    }

    public CPerson(Integer idperson) {
        this.idperson = idperson;
    }

    public CPerson(Integer idperson, String name, String vorname, String strasse, String plz, String ort, String telefon) {
        this.idperson = idperson;
        this.name = name;
        this.vorname = vorname;
        this.strasse = strasse;
        this.plz = plz;
        this.ort = ort;
        this.telefon = telefon;
    }

    public Integer getIdperson() {
        return idperson;
    }

    public void setIdperson(Integer idperson) {
        this.idperson = idperson;
    }

    public String getMitgliedsnummer() {
        return mitgliedsnummer;
    }

    public void setMitgliedsnummer(String mitgliedsnummer) {
        this.mitgliedsnummer = mitgliedsnummer;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getVorname() {
        return vorname;
    }

    public void setVorname(String vorname) {
        this.vorname = vorname;
    }

    public Date getGeburtsdatum() {
        return geburtsdatum;
    }

    public void setGeburtsdatum(Date geburtsdatum) {
        this.geburtsdatum = geburtsdatum;
    }

    public String getStrasse() {
        return strasse;
    }

    public void setStrasse(String strasse) {
        this.strasse = strasse;
    }

    public String getPlz() {
        return plz;
    }

    public void setPlz(String plz) {
        this.plz = plz;
    }

    public String getOrt() {
        return ort;
    }

    public void setOrt(String ort) {
        this.ort = ort;
    }

    public String getTelefon() {
        return telefon;
    }

    public void setTelefon(String telefon) {
        this.telefon = telefon;
    }

    public String getMobil() {
        return mobil;
    }

    public void setMobil(String mobil) {
        this.mobil = mobil;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getBeruf() {
        return beruf;
    }

    public void setBeruf(String beruf) {
        this.beruf = beruf;
    }

    public Date getEintrittsdatum() {
        return eintrittsdatum;
    }

    public void setEintrittsdatum(Date eintrittsdatum) {
        this.eintrittsdatum = eintrittsdatum;
    }

    public Date getAustrittsdatum() {
        return austrittsdatum;
    }

    public void setAustrittsdatum(Date austrittsdatum) {
        this.austrittsdatum = austrittsdatum;
    }

    public String getFunktion() {
        return funktion;
    }

    public void setFunktion(String funktion) {
        this.funktion = funktion;
    }

    public String getBeziehung() {
        return beziehung;
    }

    public void setBeziehung(String beziehung) {
        this.beziehung = beziehung;
    }

    @XmlTransient
    public Collection<CUser> getJrkUserCollection() {
        return jrkUserCollection;
    }

    public void setJrkUserCollection(Collection<CUser> jrkUserCollection) {
        this.jrkUserCollection = jrkUserCollection;
    }

    @XmlTransient
    public Collection<CPerson> getCPersonCollection() {
        return CPersonCollection;
    }

    public void setCPersonCollection(Collection<CPerson> CPersonCollection) {
        this.CPersonCollection = CPersonCollection;
    }

    public CPerson getFkIdperson() {
        return fkIdperson;
    }

    public void setFkIdperson(CPerson fkIdperson) {
        this.fkIdperson = fkIdperson;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idperson != null ? idperson.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are
        // not set
        if (!(object instanceof CPerson)) {
            return false;
        }
        CPerson other = (CPerson) object;
        if ((this.idperson == null && other.idperson != null) || (this.idperson != null && !this.idperson.equals(other.idperson))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jrkverwaltung.security.user.CPerson[ idperson=" + idperson + " ]";
    }

}
